<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%     
	String path = request.getContextPath();     
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";     
%>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title>新增</title>
	<base href="<%=basePath%>"/>
	<link rel="stylesheet" type="text/css" href="css/common.css" />
	<link rel="stylesheet" href="<%=basePath%>/js/jquery-tablesorter/themes/blue/style.css" type="text/css" media="print, projection, screen" />
	<script type="text/javascript" src="js/jquery-1.8.3.js"></script>
    <script type="text/javascript" src="js/common.js"></script>
    <script type="text/javascript" src="<%=basePath%>/js/jquery-tablesorter/jquery.tablesorter.min.js"></script>
    <script type="text/javascript" src="js/jquery.form.js"></script>
    
    <script language="JavaScript" type="text/javascript" src="js/My97DatePicker/WdatePicker.js" defer="defer"></script>	
	<style type="text/css"> 
	  fieldset,legend,form,table,tr,td,textarea{margin:0;padding:0}
	  form label {font-weight:bold;}
	  table{margin:10px 10px};
	  td{line-height: 40px;}
	  input[type="text"]{width:250px;}
	  input[type="password"]{width:250px;}
	  input[type="textarea"]{width:250px;}
	</style>

<script type="text/javascript">
  $(document).ready(function(){
	  
	  $("#resultTable").tablesorter({
     		headers:{0:{sorter:false},
     			1:{sorter:false}},
     			widgets: ['zebra']
     	});
	  
      $("#entitySchema").focus();

  });
  
//提交前验证
  function beforeSubmit() {
	  if(isEmpty($("#entitySchema").val())) { alert("实例模式名不能为空！"); return false; }
	  if(isEmpty($("#entityName").val())) { alert("实例名不能为空！"); return false; }
	  if(isEmpty($("#runCycle").val())) { alert("调度周期不能为空！"); return false; }
	     return true;
  } 
  function insert(){
	  beforeSubmit();
	  var queryString = $("#etlForm").formSerialize();
	  $.post("<%=basePath%>manage/etl?act=insert", queryString, function(data) {
			var result=eval("("+data+")");
			if(result.code == 1) {
				alert("添加成功!");
				var size = $("#size").val();
				location.href = "<%=basePath%>manage/etl?act=getPage&size="+size;
			} else {
				alert(result.message);
			}
		});
  }
  
  function backList(){
	  var size = $("#size").val();
      location.href = "<%=basePath%>manage/etl?act=getPage&size="+size;
	   }
</script>
</head>
<body  >
  <div>
    <fieldset>
      <legend>新增：</legend>
      <form id="etlForm" method="post" action="<%=basePath%>manage/etl?act=insert">
      <input type="hidden" name="size" id="size" value="${size }" />
      	<p id = "p_error" style = "margin:10px 10px;">
      	    <label id="error_label" style="color:red;"></label>
      	</p>
        <table>
          <tr>
            <td><label for="name">实例模式名：</label></td>
            <td>
            	<input type="text" name="entitySchema" id="entitySchema" value="WH" />
            	<font color="red">&nbsp;*&nbsp;&nbsp;</font>
            </td>
            <td><label for="name">实例名：</label></td>
            <td>
            	<input type="text" name="entityName" id="entityName" value="ADV" />
            	<font color="red">&nbsp;*&nbsp;&nbsp;</font>
            </td>
            <td><label for="name">调度周期：</label></td>
            <td>
            	<select name="runCycle" id="runCycle" >
            		<option value="D">日</option>
            		<option value="M">月</option>
            		<option value="W">周</option>
            		<option value="S">季</option>
            		<option value="Y">年</option>
            	</select>
            	<font color="red">&nbsp;*&nbsp;&nbsp;</font>
            </td>
         </tr>
         <tr>
            <td><label for="name">调度月份：</label></td>
            <td>
            	<input type="text" name="runMonth" id="runMonth" onfocus="WdatePicker({dateFmt:'MM'})" class="Wdate"  />
            	<font color="red">&nbsp;*&nbsp;&nbsp;</font>
            </td>
            <td><label for="name">调度日期：</label></td>
            <td>
            	<input type="text" name="runDay" id="runDay" onfocus="WdatePicker({dateFmt:'dd'})" class="Wdate"  />
            	<font color="red">&nbsp;*&nbsp;&nbsp;</font>
            </td>
            <td><label for="name">调度小时：</label></td>
            <td>
            	<input type="text" name="endHour" id="endHour" onfocus="WdatePicker({dateFmt:'HH'})" class="Wdate"  />
            	<font color="red">&nbsp;*&nbsp;&nbsp;</font>
            </td>
         </tr>
         <tr>
            <td><label for="name">调度分钟：</label></td>
            <td>
            	<input type="text" name="runMinutes" id="runMinutes" onfocus="WdatePicker({dateFmt:'mm'})" class="Wdate"  />
            	<font color="red">&nbsp;*&nbsp;&nbsp;</font>
            </td>
	  		<td><label for="name">作者：</label></td>
            <td>
            	<input type="text" name="author" id="author" value="${etlEntity.author }" />
            	<font color="red">&nbsp;*&nbsp;&nbsp;</font>
            </td>
            <td><label for="name">是否参与调度：</label></td>
            <td>
            	<select name="runEnable" id="runEnable">
            		<option value="0">不参与</option>
            		<option value="1">参与</option>
            	</select>
            	<font color="red">&nbsp;*&nbsp;&nbsp;</font>
            </td>
          	<td></td>
            <td>
            	<input type="button" id="btn_insert"  value="提交 " onclick="insert()" style="width:80px;" />
            	<input type="button" id="btn_back" value="返回" onclick="backList()" style="width:80px;" />
            </td>
          </tr>
        </table>
      </form>
    </fieldset>
  </div>
</body>
</html>